/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package sn.metier;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.ManyToOne;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 *
 * @author chenry08
 */
@Entity
public class Notification implements Serializable, Comparable<Notification> {
	//attributs
        @Id
        @GeneratedValue(strategy=GenerationType.AUTO)
	private Long id;
        
        @Column
	private Boolean isLu = false;
        
        @ManyToOne(fetch= FetchType.EAGER)
	private Personne auteur;
        
        @ManyToOne
	private Personne destinataire;
        
        @Temporal(TemporalType.TIMESTAMP)
        private Date dateNotifiee = new Date();
	
	//méthodes
	public String getNote(){
		return "plouf_Notification";
	}
	
	//constructeurs
	public Notification() {}

        public Notification(Personne auteur, Personne destinataire) {
            this.auteur = auteur;
            this.destinataire = destinataire;
        }

	
		
	//get & set
	public Personne getAuteur() {
		return auteur;
	}

	public void setAuteur(Personne auteur) {
		this.auteur = auteur;
	}

	public Personne getDestinataire() {
		return destinataire;
	}

	public void setDestinataire(Personne destinataire) {
		this.destinataire = destinataire;
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public Boolean getIsLu() {
		return isLu;
	}

	public void setIsLu(Boolean isLu) {
		this.isLu = isLu;
	}

    public Date getDateNotifiee() {
        return dateNotifiee;
    }

    public void setDateNotifiee(Date dateNotifiee) {
        this.dateNotifiee = dateNotifiee;
    }
        
        
	
	//comparateurs
	@Override
	public boolean equals(Object obj) {
		if (obj == null) {
			return false;
		}
		if (getClass() != obj.getClass()) {
			return false;
		}
		final Notification other = (Notification) obj;
		if (this.id != other.id && (this.id == null || !this.id.equals(other.id))) {
			return false;
		}
		return true;
	}

	@Override
	public int hashCode() {
		int hash = 7;
		hash = 89 * hash + (this.id != null ? this.id.hashCode() : 0);
		return hash;
	}

    @Override
    public int compareTo(Notification o) {
        return this.getDateNotifiee().compareTo(o.getDateNotifiee());
    }
	
	
}
